<template>
    <div class="app-container terminal">
        <div class="header">
            <img class="bg" src="@/assets/terminalBg.png" alt="">
            <div class="header-content" @click="navTo('/statistics')">
                <div class="top">
                    <div class="left">
                        <span>终端总数</span>
                        <img class="icon" src="@/assets/chevron-right@2x.png" alt="">
                    </div>
                    <div class="right">
                        <span>昨日唤醒</span>
                        <span style="margin-left: 10px">{{ posAll.ystdActNum || 0 }}</span>
                        <img class="icon" src="@/assets/chevron-right@2x.png" alt="">
                    </div>
                </div>
                <div class="bottom">
                    <div class="left">
                        <span class="max">{{ posAll.totalActNum ||0}}</span>
                    </div>
                    <div class="right">
                        <span>昨日唤醒</span>
                        <span style="margin-left: 10px">{{ posAll.ystdBindNum  || 0 }}</span>
                        <img class="icon" src="@/assets/chevron-right@2x.png" alt="">
                    </div>
                </div>
            </div>
        </div>
        <div class="content">
            <div class="item" @click="navTo('/admin')">
                <img src="@/assets/zdgl.png" alt="" class="left">
                <div class="right">
                    <div class="l">
                        <div class="name">
                            终端管理
                        </div>
                        <div class="num">
                            终端总数：{{ numAll||0 }}
                        </div>
                    </div>
                    <div class="r">
                        <img src="@/assets/chevron-down@2x.png" alt="">
                    </div>
                </div>
            </div>
            <div class="item" @click="navTo('/allot')">
                <img src="@/assets/zdgl.png" alt="" class="left">
                <div class="right">
                    <div class="l">
                        <div class="name">
                            终端调拨
                        </div>
                        <div class="num">
                            可调拨终端：{{ allot }}
                        </div>
                    </div>
                    <div class="r">
                        <img src="@/assets/chevron-down@2x.png" alt="">
                    </div>
                </div>
            </div>
            <div class="item" @click="navTo('/allotBank')">
                <img src="@/assets/zdgl.png" alt="" class="left">
                <div class="right">
                    <div class="l">
                        <div class="name">
                            终端回拨
                        </div>
                        <div class="num">
                            可回拨终端：{{ allotBack }}
                        </div>
                    </div>
                    <div class="r">
                        <img src="@/assets/chevron-down@2x.png" alt="">
                    </div>
                </div>
            </div>
            <div class="item" @click="navTo('/sateActive')">
                <img src="@/assets/zdgl.png" alt="" class="left">
                <div class="right"  style="border:none">
                    <div class="l">
                        <div class="name">
                            批量设置活动
                        </div>
                        <div class="num">
                            可变更终端：{{ DepositCount }}
                        </div>
                    </div>
                    <div class="r">
                        <img src="@/assets/chevron-down@2x.png" alt="">
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup name="terminal">

import {
    appStatisPosAct,
    findByCanAllotCount,
    findCanallotBackCount,
    findPageListCount,
    findSetPosActListCount
} from "../../api"
import store from "../../store"
import { showConfirmDialog } from "vant"
const posAll = ref({})
const numAll = ref(0)
const allot = ref(0)
const router = useRouter()

const allotBack = ref(0)
const DepositCount = ref(0)
const navTo = (path) => {
    if (store.state.user.userInfo.agentBean.status === "INIT") {
        showConfirmDialog({
            title: "未认证",
            message:
                "用户信息未完善，为了你的账户和资金安全请进行实名认证"
        })
            .then(() => {
                router.push({
                    path: "/addService?agentNo=" + store.state.user.userInfo.agentBean.agentNo
                })
            })
            .catch(() => {
                // on cancel
            })
        return
    }
    router.push({
        path
    })
}
const getAppStatisPosAct = ()=>{
    appStatisPosAct().then(res=>{
        posAll.value = res.object
    })
}
const getFindPageListCount = ()=>{
    findPageListCount().then(res=>{
        numAll.value = res.object
    })
}
//  获取可调拨终端数
const getFindByCanAllotCount = ()=>{
    findByCanAllotCount({}).then(res => {
        allot.value = res.object
    })
}
//  获取可回拨数量
const getFindCanAllotBackCount = ()=>{
    findCanallotBackCount({}).then(res => {
        allotBack.value = res.object
    })
}
//  获取活动变更数量
const getFindByPosDepositCount = ()=>{
    findSetPosActListCount({}).then(res => {
        DepositCount.value = res.object
    })
}
getAppStatisPosAct()
getFindPageListCount()
getFindByCanAllotCount()
getFindCanAllotBackCount()
getFindByPosDepositCount()
</script>

<style scoped lang="scss">
.app-container.terminal{
    padding: 10px;
    .header{
        font-size: 0;
        position: relative;
        .bg{
            width: 100%;
        }
        .header-content{
            padding: 10px;
            box-sizing: border-box;
            position: absolute;
            top: 0;
            left: 0;
            height: 100%;
            width: 100%;
            display: flex;
            flex-direction: column;
            justify-content: space-around;
            span{
                font-size: 16px;
                font-family: SimHei;
                color: #FFFFFF;
                opacity: 1;
            }
            .top{
                display: flex;
                align-items: center;
                justify-content: space-around;
            }
            .left,.right{
                display: flex;
                width: 50%;
                justify-content: center;
                align-items: center;
            }
            .bottom{
                display: flex;
                align-items: center;
                justify-content: space-around;
                .max{
                    font-size: 32px;
                    font-family: Source Han Sans SC;
                    font-weight: bold;
                    color: #FFFFFF;
                    opacity: 1;
                }
            }
        }
        .icon{
            width: 17px;
            margin-left: 10px;
        }
    }
    .content{
        background: #FFFFFF;
        opacity: 1;
        border-radius: 0px 0px 8px 8px;
        .item{
            display: flex;
            align-items: center;
            padding: 15px;
            .left{
                width: 42px;
            }
            .right{
                flex: 1;
                border-bottom: 1px solid #EEEEEE;
                margin-left: 10px;
                display: flex;
                align-items: center;
                justify-content: space-between;
                .l{
                    .name{
                        font-size: 16px;
                        font-family: SimHei;
                        font-weight: 400;
                        color: #45454D;
                        opacity: 1;
                    }
                    .num{
                        font-size: 11px;
                        font-family: SimHei;
                        padding: 15px 0;
                        font-weight: 400;
                        color: #A1A1B3;
                        opacity: 1;
                    }

                }
                .r{
                    img{
                        width: 20px;
                    }
                }
               }
        }
    }
}
</style>

